/**
 * @(#) NXTTouchSensor.java
 */

package pcsr.drivers.nxtDriver;

import pcsr.drivers.nxtDriver.command.INXTCommand;

class NXTTouchSensor extends NXTSensor
{
	NXTTouchSensor( NXTPort sensor, INXTCommand command ) {
		super(sensor, command);
		setTypeAndMode(NXTSensorType.SWITCH, NXTSensorMode.BOOLEAN);
	}
	
	/**
	 * @return true if sensor is pressed.
	 */
	public boolean isPressed( ) {
		return (readScaledValue() == 1);
	}

	@Override
	public NXTSensorMode[] GetAvailableModes( ) {
		return new NXTSensorMode[]{ NXTSensorMode.BOOLEAN};
	}

	@Override
	int UpdateActuatorState( ) {
		//SetSensorValue(readScaledValue());
		SetSensorValue(readBooleanValue() ? 1 : 0);
		return 0;
	}
}
